﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows;
using Bubbels.VM;

namespace Bubbels.Helper
{
    [ValueConversion(typeof(BallType), typeof(Brush))]
    public class BrushColorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var ballType = (BallType)value;

            RadialGradientBrush myBrush = new RadialGradientBrush();
            myBrush.GradientOrigin = new Point(0.75, 0.25);
            myBrush.GradientStops.Add(new GradientStop(Colors.White, 0.0));
            Color color = Colors.Transparent;

            switch (ballType)
            {
                case BallType.EMPTY:

                    break;
                case BallType.BALL1:
                    color = Colors.OrangeRed;
                    break;
                case BallType.BALL2:
                    color = Colors.Purple;
                    break;
                case BallType.BALL3:
                    color = Colors.Blue;
                    break;
                case BallType.BALL4:
                    color = Colors.Yellow;
                    break;
                case BallType.BALL5:
                    color = Colors.Green;
                    break;
                default:
                    break;
            }
            myBrush.GradientStops.Add(new GradientStop(color, 0.5));
            myBrush.GradientStops.Add(new GradientStop(Colors.Black, 1.0));

            return myBrush;

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    [ValueConversion(typeof(BallType), typeof(Color))]
    public class BallColorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var ballType = (BallType)value;

            Color color = Colors.Transparent;

            switch (ballType)
            {
                case BallType.EMPTY:

                    break;
                case BallType.BALL1:
                    color = Colors.OrangeRed;
                    break;
                case BallType.BALL2:
                    color = Colors.Purple;
                    break;
                case BallType.BALL3:
                    color = Colors.Blue;
                    break;
                case BallType.BALL4:
                    color = Colors.Yellow;
                    break;
                case BallType.BALL5:
                    color = Colors.Green;
                    break;
                default:
                    break;
            }

            return color;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

}
